extends Control

signal next(page)
var config = [
	{
		"name":"柴郡",
		"pic":"res://!ve/base/tscn/talkDlg/chaijun.png",
		"txt":"测试文本1"
	},
	{
		"name":"柴郡",
		"pic":"res://!ve/base/tscn/talkDlg/chaijun.png",
		"txt":"测试文本2"
	},
	{
		"name":"柴郡2",
		"txt":"测试文本3"
	}
]
var page = 0

func _ready():
	pass # Replace with function body.
	
func init(config):
	self.config = config
	var conf = config[0]
	$Label.text = conf.name + "："
	$RichTextLabel.bbcode_text = conf.txt
	if conf.get("pic") != null:
		$touxiang.texture = load(conf.pic)
		$touxiang.visible = true
	else:
		$touxiang.visible = false
	
func _on_RichTextLabel_gui_input(event):
	if event is InputEventMouseButton and event.pressed:
		page += 1
		if config.size() < page + 1:
			queue_free()
			return
		var conf = config[page]

		if $touxiang.visible:
			if conf.get("pic") == null:
				$touxiang.texture = null
				$touxiang.visible = false
			else:
				$touxiang.texture = load(conf.pic)
		elif conf.get("pic") != null:
			$touxiang.texture = load(conf.pic)
			$touxiang.visible = true
		
		$RichTextLabel.bbcode_text = conf.txt
		$Label.text = conf.name + "："
